<template>
	<view class="collect">
		<image v-if="dataList.length==0" src="../../../../static/image.png"></image>
		<view v-for="item in dataList">
			<image :src="item.avatar"></image>
			<view>
				<p>{{item.username}}<span>
						<image src="../../../../static/user/53.png"></image>{{item.partner_name}}
					</span></p>
				<view>{{item.intro}}</view>
			</view>
			<p>
				<image @click="deleteCollect(item.goods_id)" src="../../../../static/user/75.png"></image>
				<button
					@click="skip('/pages/appointment/appointment?name='+item.username+'&id='+item.goods_id+'&num='+item.score+'&txt='+item.intro+'&img='+item.avatar+'&eva='+item.evaluate_count)">立即预约</button>
			</p>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				falg: false,
				dataPage: 1,
				dataList: [],
			};
		},
		// 触底刷新
		onReachBottom() {
			if (this.falg) {
				this.getCollectList();
			}
		},
		// 下拉刷新
		onPullDownRefresh() {
			this.dataPage = 1;
			this.falg = true;
			this.dataList = [];
			this.getCollectList();
			uni.stopPullDownRefresh();
		},
		methods: {
			getCollectList() {
				this.$httpRequest('/goods/getGoodsCollectList').then(res => {
					if (res.data.last_page > res.data.current_page) {
						this.datePage++;
					} else {
						this.falg = false
					}
					this.dataList.push(...res.data.data);
				});
			},
			skip(url) {
				uni.redirectTo({
					url,
				})
			},
			deleteCollect(id) {
				this.$httpRequest('/goods/collect', {
					tech_id: id
				}).then(() => {
					this.dataPage = 1;
					this.falg = true;
					this.dataList = [];
					this.getCollectList();
				})
			}
		},
		onLoad() {
			this.getCollectList();
		}
	}
</script>

<style lang="less">
	.collect {
		padding-top: 36rpx;

		&>image {
			width: 616rpx;
			height: 616rpx;
			display: block;
			margin: 100rpx auto 0;
			image-rendering: -moz-crisp-edges;
			image-rendering: -o-crisp-edges;
			image-rendering: -webkit-optimize-contrast;
			image-rendering: crisp-edges;
			-ms-interpolation-mode: nearest-neighbor;
		}

		&>view {
			width: 690rpx;
			background-color: #fff;
			border-radius: 10rpx;
			margin: 0 auto 20rpx;
			padding: 20rpx;
			box-sizing: border-box;
			display: flex;
			justify-content: space-between;
			color: #333;

			&>p {
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: center;

				&>image {
					width: 30rpx;
					height: 28rpx;
					margin-bottom: 40rpx;
					image-rendering: -moz-crisp-edges;
					image-rendering: -o-crisp-edges;
					image-rendering: -webkit-optimize-contrast;
					image-rendering: crisp-edges;
					-ms-interpolation-mode: nearest-neighbor;
				}

				&>button {
					width: 134rpx;
					height: 50rpx;
					line-height: 50rpx;
					color: #9E9E9E;
					font-size: 12px;
					padding: 0;
					border-radius: 25rpx;
					background: #EDEDED;
					border: 1px solid #B6B6B6;
				}
			}

			&>view {
				width: 304rpx;
				display: flex;
				flex-direction: column;
				justify-content: center;

				&>view {
					font-size: 12px;
					color: #999999;
					overflow: hidden;
					text-overflow: ellipsis;
					display: -webkit-box !important;
					-webkit-line-clamp: 2;
					-webkit-box-orient: vertical;
					margin-top: 14rpx;
				}

				&>p {
					font-size: 13px;
					display: flex;
					align-items: center;

					&>span {
						color: #666;
						font-size: 11px;
						display: flex;
						align-items: center;

						&>image {
							width: 26rpx;
							height: 26rpx;
							margin: 0 12rpx 0 40rpx;
							image-rendering: -moz-crisp-edges;
							image-rendering: -o-crisp-edges;
							image-rendering: -webkit-optimize-contrast;
							image-rendering: crisp-edges;
							-ms-interpolation-mode: nearest-neighbor;
						}
					}
				}
			}

			&>image {
				width: 132rpx;
				height: 146rpx;
				image-rendering: -moz-crisp-edges;
				image-rendering: -o-crisp-edges;
				image-rendering: -webkit-optimize-contrast;
				image-rendering: crisp-edges;
				-ms-interpolation-mode: nearest-neighbor;
			}
		}
	}
</style>